package com.gf.exam.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.gf.base.type.Activity;
import com.gf.exam.model.Answer;

/**
 * 
 * @author zhuguifeng guifeng.net@gmail.com
 * @version 创建时间：2012-12-8 上午10:40:48
 */
public class AnswerMapper implements RowMapper<Answer> {

	private static final AnswerMapper MAPPER = new AnswerMapper();

	private static final String COLUME_ID = "id";
	private static final String COLUME_EXAMID = "examId";
	private static final String COLUME_CELLNO = "cellNo";
	private static final String COLUME_USERID = "userId";
	private static final String COLUME_USERNAME = "username";
	private static final String COLUME_CREATETIME = "createtime";
	private static final String COLUME_ACTIVITY = "activity";

	public static AnswerMapper getMapper() {
		return MAPPER;
	}

	@Override
	public Answer mapRow(ResultSet set, int row) throws SQLException {
		Answer answer = new Answer();

		answer.setId(set.getLong(COLUME_ID));
		answer.setExamId(set.getLong(COLUME_EXAMID));
		answer.setCellNo(set.getInt(COLUME_CELLNO));
		answer.setUserId(set.getLong(COLUME_USERID));
		answer.setUsername(set.getString(COLUME_USERNAME));
		answer.setCreatetime(set.getTimestamp(COLUME_CREATETIME));
		answer.setActivity(Activity.valueOf(set.getString(COLUME_ACTIVITY)));

		return answer;
	}

}
